{include file="public/header" /}

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5><font style="color:green">{$customer.nickname}</font> 的上级详情</h5>
                    <h5 style="float:right">
                        <a href="javascript:history.go(-1)" style="color:green">返回 ></a></h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="add" id="add" method="post">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">微信号：</label>
                            <div class="input-group col-sm-4">
                                <input type="text" class="form-control" value="{$parentCustomer.nickname}" readonly >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">历史总收益：</label>
                            <div class="input-group col-sm-4">
                                <input type="text" class="form-control" value="{$parentCustomer.history_profit}" readonly >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">推广位：</label>
                            <div class="input-group col-sm-4">
                                <input type="text" class="form-control" value="{$parentCustomer.yx_pid}" readonly >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <a href="{:url('edit', ['id'=>$parentCustomer.id])}" class="btn btn-primary"><i class="fa fa-info"></i> 上级详情</a>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:;" onclick="relieveParent()"><i class="fa fa-close"></i> 解除关系</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
function relieveParent() {
    layer.confirm('确定要解除关系吗？', {icon: 3}, function(index){
        $.ajax({
            url: "{:url('relieveParentCustomer')}",
            type: "post",
            data: {
                customer_id: '{$customer.id}'
            },
            dataType: "json",
            beforeSend:function() {
                // 显示loading
                index2 = layer.load(0, {
                    shade: [0.3,'#fff']
                });
            },
            success:function(data) {

                if (data['code'] != 1) {

                    layer.msg(data.msg,{icon:2,time:1000,shade: 0.1,}, function(index){
                        layer.close(index)
                    });
                    return false;
                }

                layer.msg(data.msg, {icon: 1,time:1000,shade:0.1}, function(index) {
                    window.location.href="{:url('edit')}?id="+'{$customer.id}'
                });
            },
            complete:function() {
                // 隐藏loading
                layer.close(index2);
            }
        });
    });
}
</script>
</body>
</html>